import operate from '@dfeidao/atom-nodejs/db/operate';
import log from '@dfeidao/atom-nodejs/logger/log';
interface Message {
	atomm: [{
		level_no: string;
		level_name: string;
		order_num: string;
	}];
}

export default async function atom(msg: Message, action_id: string, session_id: string) {
	log('Service begin');
	// todo
	const { update, exec } = operate(action_id, session_id, '12');
	for (let i = 0; i < msg.atomm.length; i++) {
		update('tenant_level', { level_no: msg.atomm[i].level_no, level_name: msg.atomm[i].level_name }, { order_num: msg.atomm[i].order_num });

	}
	log('Service end');
	const ret = await exec();
	return ret.code;
}
